package com.xiezc.util;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;

import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * Created by xiezc on 17/1/16.
 */
public abstract class RespUtil {

    /**
     * 返回json数据的工具类
     *
     * @param resp
     * @param jsonObject
     * @throws IOException
     */
    public static void respJSON(HttpServletResponse resp, JSON jsonObject) throws IOException {
        resp.setCharacterEncoding("utf8");
        resp.setContentType("application/json;charset=utf-8");
        resp.getWriter().print(jsonObject.toJSONString());
        resp.flushBuffer();
    }
}
